package com.rui.cn.consumer.common;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class PasswordUtil {
    /**
     *@ 描述：shiro 基于用户的盐值加密
     *@ 方法名：returnPass
     *@ 参数：[userName, password]
     *@ 返回值类型：java.lang.Object
     *@ 创建人：[zhang]
     *@ 创建时间：2018/4/30 0030-上午 1:21
     **/
    public static String returnPass(String userName,String password){
        String hashAlgorithmName = "md5";
        Object credentials = password;
        Object salt = ByteSource.Util.bytes(userName);;
        int hashIterations = 2;
        SimpleHash result = new SimpleHash(hashAlgorithmName, credentials, salt, hashIterations);
        return  result.toString();
    }
    public static void main(String[] args){
        PasswordUtil.returnPass("admin","admin");
    }
}
